Kotlin
Impressions
-
I was quite discouraged by how verbose the language can be, etc. Not great for Godot.
-
Didn't impress me, but seemed solid.
-
I like having 'first-class functions'.
About
-
Designed to replace Java, due to much easier-to-read syntax.
-
Default access control: Public.
-
Although the global default is
public, Kotlin usesprivatefor members defined within nested or local classes when no visibility is specified.
class MyClass { private class PrivateClass { } // Private by default } -
Compatibility
-
Multiplatform:
-
Widely used for Android development.
-
-
Java:
-
Compatible with Java, as the compiled code becomes Java.
-
-
JavaScript:
-
"Can also be compiled to JavaScript, Native LLVM, and any JVM, making it suitable for building web applications."
-
Syntax
fun main() {
var hello = 'hi mom'
println(hello)
}
-
Has static typing.
-
The language uses camelCase for its functions.
-
:/ annoying.
-
-
Uses
varto declare variables (mutable variable). -
Uses
valto declare constants (immutable variable). -
Has automatic type inference, so both of these are equivalent:
var hello = 'hi mom' var hello: String = 'hi mom' -
Has 'null safety', using
?to allow the type to be null.var hello: String? = 'hi mom'-
Makes
hellonullable.
-
-
The use of
;is optional. -
Functions are 'first class objects', which is very good.
-
Can create lambdas, pass as parameters, etc.
-
Game Dev
Godot Kotlin
-
-
Demo .
-
-
Treated as a module, not as a GDExtension.
-
"Just write your game scripts like you would for GDScript or for C# but with all the syntactic sugar of Kotlin."
Old
-
Kotlin Native Binding for Godot.-
Only for Godot 3.2.
-
This state will not change in the near foreseeable future. The Kotlin Native performance is not where it needs to be to make this binding efficient. Currently, the build times are incredibly slow due to the lack of incremental build support in Kotlin Native. Also, the runtime performance is much slower than GDScript in many cases.
-